package top.tsyz.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.tsyz.entity.UserAddress;
import top.tsyz.service.IUserAddressService;

import java.util.List;

/**
 * UserAddressController控制器
 */
@RestController
@RequestMapping("/api/userAddresses")
@Api(tags = "UserAddress管理接口")
public class UserAddressController {

    @Autowired
    private IUserAddressService iuseraddressservice;

    @GetMapping("/list")
    @ApiOperation("获取所有UserAddress")
    public List<UserAddress> list() {
        return iuseraddressservice.list();
    }

    @GetMapping("/{id}")
    @ApiOperation("根据ID获取UserAddress")
    public UserAddress getById(@PathVariable Long id) {
        return iuseraddressservice.getById(id);
    }

    @PostMapping
    @ApiOperation("新增UserAddress")
    public boolean save(@RequestBody UserAddress useraddress) {
        return iuseraddressservice.save(useraddress);
    }

    @PutMapping
    @ApiOperation("更新UserAddress")
    public boolean update(@RequestBody UserAddress useraddress) {
        return iuseraddressservice.updateById(useraddress);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除UserAddress")
    public boolean delete(@PathVariable Long id) {
        return iuseraddressservice.removeById(id);
    }
}
